fix(app-scripts): raise TLD character limit in allowNetworks validati…#2972
Conversation
…on from 6 to 63
The regex used in `isValidNetwork` capped TLD length at 6 characters
({2,6}), which incorrectly rejected valid domains whose TLD is longer
than 6 characters (e.g. .hosting, .international, .construction).
The upper bound is raised to 63, which is the maximum length of a single
DNS label as defined by RFC 1035 §2.3.4. This is not arbitrary — it is
the hard protocol-level ceiling that ICANN itself enforces when approving
new TLDs. Since ICANN opened the generic TLD (gTLD) programme in 2012,
hundreds of long TLDs have been delegated, making the previous limit of 6
both technically incorrect and a source of real customer friction.
Fixes: customer was unable to upload a custom app using the allowNetworks
entry `qa-gql-gateway.akzonobel.hosting` because `.hosting` (7 chars)
exceeded the old limit.
The outbound worker (functions-api-outbound-worker) is not affected — it
uses the `tldts` library backed by the Public Suffix List, which has no
character-length restriction and already handles long TLDs correctly.
Made-with: Cursor
Code Review Agent Run #217d9dActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Changelist by BitoThis pull request implements the following key changes.
|
Impact Analysis by BitoInteraction DiagramsequenceDiagram
participant Dev as Developer
participant CLI as ContentfulAppScripts
participant Upload as Upload Module
participant Build as BuildUploadSettings Function
participant GetFunc as GetFunctionsFromManifest Function
participant ValidNet as IsValidNetwork Function<br/>🔄 Updated | ●●○ Medium
participant Manifest as Manifest JSON
GetFunc->>Manifest: Read functions from file
Dev->>CLI: Run upload command
CLI->>Upload: Execute upload
Upload->>Build: Build upload settings
Build->>GetFunc: Get validated functions
GetFunc->>ValidNet: Validate allowNetworks
ValidNet-->>GetFunc: Return validation result
alt [networks valid]
GetFunc-->>Build: Return functions
Build-->>Upload: Return settings
Upload-->>CLI: Proceed with upload
CLI-->>Dev: Upload successful
else [invalid networks]
GetFunc->>CLI: Exit with validation error
CLI-->>Dev: Upload failed
end
This merge request updates the isValidNetwork function to support top-level domains (TLDs) up to 63 characters, enabling validation of modern long generic TLDs like .hosting and .international. It modifies the regex pattern in the data validation layer and adds comprehensive test cases. This change allows app uploads with functions specifying allowNetworks containing domains with extended TLDs, which were previously blocked by the restrictive {2,6} limit. Cross-Repository Impact Analysis
Code Paths AnalyzedImpact: Flow: Direct Changes (Diff Files): Repository Impact: Cross-Repository Dependencies: Database/Caching Impact: API Contract Violations: Infrastructure Dependencies: Additional Insights: Testing RecommendationsFrontend Impact: Service Integration: Data Serialization: Privacy Compliance: Backward Compatibility: OAuth Functionality: Reliability Testing: Additional Insights: Analysis based on known dependency patterns and edges. Actual impact may vary. |
Problem
The
isValidNetworkregex inpackages/contentful--app-scripts/src/utils.tscapped TLD length at 6 characters ({2,6}), causing the CLI to incorrectly reject validallowNetworksentries for domains with TLDs longer than 6 characters.A customer was blocked from uploading their custom app because
qa-gql-gateway.akzonobel.hostingfailed validation —.hostingis 7 characters, one over the arbitrary limit.Zendesk: https://contentful.atlassian.net/browse/ZEND-7697
Root Cause
The
{2,6}upper bound was arbitrary and predated ICANN's 2012 generic TLD (gTLD) expansion, which introduced hundreds of TLDs longer than 6 characters (.hosting,.international,.construction, etc.).Solution
Raise the TLD upper bound from
6to63in both regex positions insideisValidNetwork. The value 63 is the maximum length of a single DNS label as defined by RFC 1035 §2.3.4 — the hard protocol ceiling that ICANN itself enforces when approving new TLDs.Tests Added
Four new cases in
src/utils.test.ts:qa-gql-gateway.akzonobel.hosting(exact customer URL)*.akzonobel.hosting(wildcard with long TLD)All 17 tests pass (13 pre-existing + 4 new).
Scope
isValidNetworkregex — this PRNETWORK_RE(extensibility-api)functions-api)tldts(PSL-backed, no char limit)user_interface)